<template>
	<!-- <view>
		<image class="bg" src="/static/login/log_bg.png" mode="scaleToFill"></image> -->
	<view class="content" :style="{'background':kbackgroundColor}" style="min-height: 100vh">

		<hx-navbar title="实名认证" :back="true" :fixed="false" :color="knavTitleColor" barPlaceholder="hidden" transparent="auto"></hx-navbar>
		<view class="container">
			<block v-if="!info.isCertified">
				<view class="cont-box" :style="{background:kcellBgColor}">
					<view class="settings_item">
						<view class="settings_name">真实姓名</view>
						<input type="text" :placeholderStyle="placeholderStyle" v-model="true_name" class="value"
							placeholder="请输入真实姓名" />
					</view>
					<view class="settings_item">
						<view class="settings_name">身份证号 </view>
						<input type="text" :placeholderStyle="placeholderStyle" v-model="card" class="value"
							placeholder="请输入有效身份证号码" />
					</view>
					<view class="settings_item">
						<view class="settings_name">手机号码</view>
						<input disabled type="text" v-model="info.phone" class="value" placeholder="请输入手机号"
							:placeholderStyle="placeholderStyle" />
					</view>
				</view>
				<view class="tips_box">
					<n-icon name="info" color="#FE005A"></n-icon>
					<view class="list" :style="{color:knormalColor}">
						<view class="text">*实名认证仅限年满18周岁(不含)到60周岁(含)之间的中国大陆用户</view>
						<view class="text">*您填写的实名认证信息，须和您的注册手机号所绑定的身份信息一致</view>
						<view class="text">*未经您的授权，您的身份信息不会用于其他用途</view>
						<view style="font-size: 29rpx;line-height: 3;color:#DF0303;">*获取数字科技商品奖励须进行实名认证</view>
					</view>
				</view>
				<view class="submit" @click="submit()" :style="{background:kbuttonBgColor,color:knavgroundColor,border:kborderSty}">立即认证</view>
			</block>
			<view class="container2" v-else>
				<image class="renzhengok" v-if="ktheme != 'black'" src="/static/user/renzheng_ok.png" mode="widthFix"></image>
				<image class="renzhengok" v-else src="/static/user/renzheng_ok_yellow.png" mode="widthFix"></image>
				<view class="renzhengok_text" :style="{color:knormalColor}">
					您已经实名认证成功，请勿重复实名认证
				</view>
				<view class="submit" @tap="go_index()" :style="{background:kbuttonBgColor,color:knavgroundColor,border:kborderSty}">返回首页</view>
			</view>
		</view>
	</view>
</template>

<script>
  export default {
		data() {
			return {
				placeholderStyle: 'font-size: 28rpx;color: #999;',
				is_agree: false,
				info: {},
				true_name: '',
				card: '',
				mobile: '',
				bankcard: '',
				applyed: false,
			}
		},
		onLoad() {
			this.$api.userAccount({}, res => {
				if (res.status) {
					this.info = res.data;
          if (res.data.isCertified) {
            // 已实名
            this.$api.userInfo({}, res_init => {
              if (res_init.status && res_init.data.walletStatus) {
                if(res_init.data.walletStatus.hfStatus == 1 || res_init.data.walletStatus.sdStatus == 1) {
                  // 已开户
                } else {
                  let invite_way = uni.getStorageSync('invite_way')
                  if (invite_way === 'ai') {
                    uni.navigateTo({
                      url: '/pages/aipicture/finish/ai_invite'
                    })
                  } else {
                    uni.navigateTo({
                      url: '/pages/aipicture/finish/normal_invite'
                    })
                  }
                }
              }
            });
          } else {
            // 未实名
          }
				}
			})
		},
		methods: {
			go_user: function() {
				uni.switchTab({
					url: '/pages/user/user'
				})
			},
			go_index: function() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			},

			// 跳转到用户协议
			goAgreement() {
				let articleId = this.$store.state.config.user_agreement_id;
				this.$common.navigateTo('/pages/article/index?id_type=1&id=' + articleId);
			},
			// 跳转到隐私政策
			goPrivacy() {
				let articleId = this.$store.state.config.privacy_policy_id;
				this.$common.navigateTo('/pages/article/index?id_type=1&id=' + articleId);
			},
			agree: function() {
				this.is_agree = !this.is_agree
			},
			submit: function() {
				let data = {
					realName: this.true_name,
					idCard: this.card,
				}

				if (this.info.isCertified) {
					this.$common.errorToShow('您已经认证过了');
					return;
				}

				this.$api.realName(data, res => {
					if (res.status) {
						this.$common.successToShow("实名认证成功", () => {
							uni.navigateBack({})
						})
					} else {
						this.$common.errorToShow(res.message)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 20rpx 40rpx;
		position: relative;
		z-index: 2;
	}
	.container2 {
		padding: 180rpx 0;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.renzhengok {
		width:230rpx;
		height: 266rpx;
		margin-top: 200rpx;
		margin-bottom: 100rpx;
	}
	.renzhengok_text {
		font-size: 28rpx;
		font-weight: 400;
		color: #000000;
		position: relative;
		z-index: 2;
	}
	.cont-box {
		z-index: 2;
		padding: 10rpx 30rpx;
		background-color: $bg-box;
		border-radius: 20rpx;
		position: relative;
		.settings_item {
			padding: 30rpx 0;
			display: flex;
			align-items: center;
			.settings_name {
				font-size: 24rpx;
				color: #666;
			}
			.value {
				flex: 1;
				text-align: right;
				font-size: 28rpx;
				color: #000;
			}
			.text {
				display: flex;
				align-items: center;
				image {
					width: 17rpx;
					height: 17rpx;
					display: block;
					margin-left: 10rpx;
				}
			}
		}
	}
	.tips_box {
		display: flex;
		justify-content: space-between;
		margin-top: 40rpx;
		.list {
			width: 634rpx;
			font-size: 23rpx;
			color: #000;
			// color: var(--tabNormalColor);
			line-height: 1.6;
		}
	}
	.submit {
		width: 650rpx;
			height: 90rpx;
		background-color: #FFE4E8;
		border-radius: 45rpx;
		border: 1px solid #FE005A;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 32rpx;
		color: #FE005A;
		font-weight: 400;
		position: fixed;
		left: 50%;
		bottom: 50rpx;
		z-index: 2;
		transform: translateX(-50%);
	}
</style>
